package main
import "fmt"

func gcd(a,b int)(ans int){
	if (a%b==0){
		ans = b
	}else{
		ans = gcd(b,a%b)
	}
	return
}

func main(){
	var n,m int
	fmt.Scanf("%d%d",&n,&m)
	fmt.Println(gcd(n,m))
}